<?php

namespace User\Form\Fieldset;

use User\Model\Entity\ModuleSettings;
use Zend\Form\Fieldset;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;

class ModuleSettingsFieldset extends Fieldset implements InputFilterProviderInterface {
    public function __construct() {
    	parent::__construct('module_settings');
        $this->setHydrator(new ClassMethodsHydrator(false))
             ->setObject(new ModuleSettings());
        
       	$this->add(array(
            'name' => 'id',
            'attributes' => array(
                'type'  => 'hidden',
            ),
        ));
        
       	$this->add(array(
            'name' => 'loginRoute',
            'attributes' => array(
                'type' => 'text',
       			'class' => 'form-control',
            ),
            'options' => array(
                'label' => 'Login Route',
                'label_attributes' => array( 
            		'class' => 'col-lg-2 control-label', 
        		),
            ),
        ));
        
       	$this->add(array(
            'name' => 'redirectRouteLogin',
            'attributes' => array(
                'type' => 'text',
       			'class' => 'form-control',
            ),
            'options' => array(
                'label' => 'Login Redirect Route',
                'label_attributes' => array( 
            		'class' => 'col-lg-2 control-label', 
        		),
            ),
        ));
        
       	$this->add(array(
            'name' => 'redirectRouteLogout',
            'attributes' => array(
                'type' => 'text',
       			'class' => 'form-control',
            ),
            'options' => array(
                'label' => 'Logout Redirect Route',
                'label_attributes' => array( 
            		'class' => 'col-lg-2 control-label', 
        		),
            ),
        ));
        
     	$this->add(array(
        	'type' => 'Zend\Form\Element\Select',
            'name' => 'loginAfterRegistration',
     		'attributes' => array(
       			'class' => 'form-control',
            ),
            'options' => array(
                'label' => 'Login After Registration',
            	'label_attributes' => array( 
            		'class' => 'col-lg-2 control-label',
        		),
        		'empty_option' => 'Select',
                'value_options' => array(
                    '0' => 'No',
                    '1' => 'Yes'
                ),
            ),
        ));
        
     	$this->add(array(
        	'type' => 'Zend\Form\Element\Select',
            'name' => 'registrationEnable',
     		'attributes' => array(
       			'class' => 'form-control',
            ),
            'options' => array(
                'label' => 'Enable Registration',
            	'label_attributes' => array( 
            		'class' => 'col-lg-2 control-label',
        		),
        		'empty_option' => 'Select',
                'value_options' => array(
                    '0' => 'No',
                    '1' => 'Yes'
                ),
            ),
        ));
        
     	$this->add(array(
        	'type' => 'Zend\Form\Element\Select',
            'name' => 'registrationUseFormCaptcha',
     		'attributes' => array(
       			'class' => 'form-control',
            ),
            'options' => array(
                'label' => 'Registration Captcha',
            	'label_attributes' => array( 
            		'class' => 'col-lg-2 control-label',
        		),
        		'empty_option' => 'Select',
                'value_options' => array(
                    '0' => 'No',
                    '1' => 'Yes'
                ),
            ),
        ));
    }

    /**
     * Should return an array specification compatible with
     * {@link Zend\InputFilter\Factory::createInputFilter()}.
     *
     * @return array
     */
    public function getInputFilterSpecification() {
        return array(
        	'loginRoute' => array(
                'required' => true,
                'filters'  => array(
                    array('name' => 'StringTrim'),
                ),
                'validators' => array(
                    array(
                        'name'    => 'StringLength',
                        'options' => array(
                            'min' => 2,
                            'max' => 100,
                        ),
                    ),
                ),
            ),
        	'redirectRouteLogin' => array(
                'required' => true,
                'filters'  => array(
                    array('name' => 'StringTrim'),
                ),
                'validators' => array(
                    array(
                        'name'    => 'StringLength',
                        'options' => array(
                            'min' => 2,
                            'max' => 100,
                        ),
                    ),
                ),
            ),
        	'redirectRouteLogout' => array(
                'required' => true,
                'filters'  => array(
                    array('name' => 'StringTrim'),
                ),
                'validators' => array(
                    array(
                        'name'    => 'StringLength',
                        'options' => array(
                            'min' => 2,
                            'max' => 100,
                        ),
                    ),
                ),
            ),
        );
    }
}